//
//  AnimatorStore.swift
//  DYSwiftFramework
//
//  Created by 黄德玉 on 2018/8/16.
//  Copyright © 2018年 none. All rights reserved.
//

import UIKit

extension Animator {
    
    public class func AnimatorWithName(name:String,timeDuration:TimeInterval,parameters:Any?)->Animator{
        let animator:Animator = Animator();
        animator.timeDuration = timeDuration;
        animator.name = name;
        animator.extraPars = parameters;
        switch name {
        case "defaultPush":
            animator.action = defaultToAnimator
        case "defaultBack":
            animator.action = defaultBackAnimator
        default:
            animator.action = nil;
        }
        return animator;
    }
}

// 默认push动画
func defaultToAnimator(context:UIViewControllerContextTransitioning,timeDuration:TimeInterval) -> Void {
    let containerView = context.containerView
    let fromVC = context.viewController(forKey: .from)
    let toVC = context.viewController(forKey: .to)
    
    if let _ = fromVC,let to = toVC {
        containerView.addSubview(to.view)
        UIView.animate(withDuration: timeDuration) {
        
        }
    }
}

//默认back动画
func defaultBackAnimator(context:UIViewControllerContextTransitioning,timeDuration:TimeInterval)->Void{
    
}






